home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_02
/
9n02014a
< prev
next >
Wrap
Text File
|
1991-01-20
|
1KB
|
55 lines
Listing 2
/* test limits macros
* copyright (c) 1991 by P.J. Plauger
*/
#include <limits.h>
#include <stdio.h>
/* test basic properties of limits.h macros
*/
int main()
{
<%-2>#if CHAR_BIT < 8 || CHAR_MAX < 127 || 0 < CHAR_MIN \
<%0> || CHAR_MAX != SCHAR_MAX && CHAR_MAX != UCHAR_MAX
#error bad char properties
#endif
#if INT_MAX < 32767 || -32767 < INT_MIN \
|| INT_MAX < SHRT_MAX
#error bad int properties
#endif
#if LONG_MAX < 2147483647 \
|| -2147483647 < LONG_MIN \
|| LONG_MAX < INT_MAX
#error bad long properties
#endif
#if MB_LEN_MAX < 1
#error bad MB_LEN_MAX
#endif
#if SCHAR_MAX < 127 || -127 < SCHAR_MIN
#error bad signed char properties
#endif
#if SHRT_MAX < 32767 || -32767 < SHRT_MIN \
|| SHRT_MAX < SCHAR_MAX
#error bad short properties
#endif
#if UCHAR_MAX < 255 || UCHAR_MAX <= 2 * SCHAR_MAX
#error bad unsigned char properties
#endif
#if UINT_MAX < 65535 || UINT_MAX <= 2 * INT_MAX \
|| UINT_MAX < USHRT_MAX
#error bad unsigned int properties
#endif
<%4>#if ULONG_MAX < 4294967295 \
|| ULONG_MAX <= 2 * LONG_MAX \
<%0> || ULONG_MAX < UINT_MAX
#endif
<%-2>#if USHRT_MAX < 65535 || USHRT_MAX <= 2 * SHRT_MAX \
<%0> || USHRT_MAX < UCHAR_MAX
#error bad unsigned short properties
#endif
puts("SUCCESS testing <limits.h>");
return (0);
}